﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tesla.DataAccess.DataAccessLogic.Interfaces;
using Tesla.Util.Utilities;

namespace Tesla.DataAccess.DataAccessLogic.Implementations
{
    public class ContextDA : IBaseDA, IDisposable
    {
        public object CreateSpecializedDA(int id)
        {
            IBaseDA instance = GenericClassFactory<int, IBaseDA>.CreateInstance(id);
            if (instance == null)
            {
                string typeName = ResolveMapper.ResolveMethod(id);
                Type type = Type.GetType(typeName);
                GenericClassFactory<int, IBaseDA>.Add(id, type);
                instance = GenericClassFactory<int, IBaseDA>.CreateInstance(id) as IBaseDA;
            }
            return instance;

        }

        #region IDisposable Members

        void IDisposable.Dispose()
        {

            GC.SuppressFinalize(this);
        }

        #endregion

    }
     
}
